package com.mriassl.stream.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mriassl.stream.constant.TransactionType;
import com.mriassl.stream.mapper.BetMapper;
import com.mriassl.stream.mapper.TransactionMapper;
import com.mriassl.stream.service.TransactionService;

@Service
public class TransactionServiceImpl implements TransactionService {

    @Autowired
    private TransactionMapper transactionMapper;
    
    @Autowired
    private BetMapper betMapper;
    
    @Override
    @Transactional
    public void deleteTransactionByOrderno(String orderno) {
        transactionMapper.deleteTransactionByOrderno(orderno);
    }

    @Override
    @Transactional
    public void finishBettingTransaction(String orderno) {
        betMapper.finishBettingPay(orderno.substring(TransactionType.BETTING.getIndex()));
        transactionMapper.deleteTransactionByOrderno(orderno);
    }

}
